package UdpDemon;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class UdpClientDemon01 {
    public static void main(String[] args) throws Exception {
        // don't need to connect Server
        // 1. establish a socket
        DatagramSocket socket=new DatagramSocket();
        // 2. create a package
        String msg="你好啊，服务器！";
        InetAddress localHost=InetAddress.getByName("localhost");
        int port=9090;
        // data,start,end,who
        DatagramPacket packet=new DatagramPacket(msg.getBytes(),0,msg.length(),localHost,port);
        // 3. send the package
        socket.send(packet);
        // 4. close socket
        socket.close();
    }
}
